package com.plian.system.service.fr.audit.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.plian.system.entity.fr.audit.AuditProject;
import com.plian.system.mapper.fr.audit.AuditProjectMapper;
import com.plian.system.mybatis.base.BaseServiceImpl;
import com.plian.system.service.fr.audit.IAuditProjectService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;


/**
 * 审计项目 服务实现类
 *
 * @author gangan
 * @since 2019-09-27
 */
@Slf4j
@Service
@AllArgsConstructor
public class AuditProjectServiceImpl extends BaseServiceImpl<AuditProjectMapper, AuditProject> implements IAuditProjectService {

    @Override
    public Boolean deleteLogicByReportId(List<Long> ids) {
        LambdaQueryWrapper<AuditProject> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(AuditProject::getAuditReportId, ids);
        List<AuditProject> auditProjects = list(queryWrapper);
        if (!CollectionUtils.isEmpty(auditProjects)){
            return deleteLogic(auditProjects.stream().map(AuditProject::getId).collect(Collectors.toList()));
        }
        return true;
    }

}
